import type { StepProps } from 'ant-design-vue';

type DistributionConfig = {
  templateId: string;
  productId: string;
  stationId: string;
  tagCode: string;
  resolutionId: string;
  tagId: string;
};
export const distributionObj: DistributionConfig = {
  templateId: '',
  productId: '',
  tagCode: '',
  stationId: '',
  resolutionId: '',
  tagId: '',
};
export const distributionConfig = ref<DistributionConfig>({ ...distributionObj });

export const currentStep = ref(-1);
/* 当前位置不能随意变化 */
export const distributionSteps = ref<StepProps[]>([
  {
    title: '选择商品',
    description: '请选择商品',
  },
  {
    title: '选择模板',
    description: '请选择模板',
  },
  {
    title: '选择标签',
    description: '请选择标签',
    disabled: true,
  },
]);
export enum DISTRIBUTE_STEP {
  PRODUCT = 0,
  TAG = 2,
  TEMPLATE = 1,
}
interface DistributionStep {
  index: DISTRIBUTE_STEP;
  value: string;
  key: 'templateId' | 'productId' | 'tagCode';
}

export const setDistributionStep = (step: DistributionStep) => {
  if (step.value) {
    distributionSteps.value[step.index].status = 'finish';
    distributionSteps.value[step.index].description = step.value;
    distributionConfig.value[step.key] = step.value;
  }
};
